package pkg

import (
	"encoding/json"
	"fmt"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
)

// 百度文本审核
func Baidu(res string) bool {
	client := censor.NewClient("o835WXQSFVy7KOmsAFSaLUIC", "oldv7Ka8xgEFFJnf7ZiE7FXA7ojbWyPv")

	res = client.TextCensor(res)
	fmt.Println(res)
	resData := map[string]interface{}{}
	err := json.Unmarshal([]byte(res), &resData)
	if err != nil {
		return false
	}
	if resData["conclusion"] == "不合规" {
		return false
	}
	return true
}
